#include "faliure.h"
#include <QPainter>
#include "mypushbutton.h"
#include <QDebug>
#include <QTimer>

Faliure::Faliure(QWidget *parent) : QMainWindow(parent)
{
    this->setFixedSize(1200,800);

    this->setWindowIcon(QPixmap(":/pictures/title.png"));

    this->setWindowTitle("失败");

    MyPushButton * toBtn = new MyPushButton(":/pictures/tomain.png");
    toBtn->setParent(this);
    toBtn->move(900,620);

    MyPushButton * quitBtn = new MyPushButton(":/pictures/quitbutton.png");
    quitBtn->setParent(this);
    quitBtn->move(100,600);

    connect(toBtn,&MyPushButton::clicked,[=](){

        toBtn->zoom1();
        toBtn->zoom2();

        QTimer::singleShot(500,this,[=](){
            emit this->feb();
        });
    });

    connect(quitBtn,&MyPushButton::clicked,[=](){

        quitBtn->zoom1();
        quitBtn->zoom2();

        QTimer::singleShot(500,this,[=](){
            this->close();
        });
    });

}

void Faliure::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/pictures/gameover.png");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
